package com.xiaochi.wx.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author zqx
 * @since 2024/8/31
 */
@Component
@Slf4j
public class SubscribeMsgHandler implements WxChatMsgHandler{

    @Override
    public WxchatMsgTypeEnum getMsgType() {
        return WxchatMsgTypeEnum.SUBSCRIBE;
    }

    @Override
    public String dealMsg(Map<String, String> messMap) {
        log.info("用户关注事件");
        String fromUserName = messMap.get("FromUserName");
        String toUserName = messMap.get("ToUserName");
        String msg = "<xml>\n" +
                "  <ToUserName><![CDATA["+ fromUserName +"]]></ToUserName>\n" +
                "  <FromUserName><![CDATA["+ toUserName +"]]></FromUserName>\n" +
                "  <CreateTime>12345678</CreateTime>\n" +
                "  <MsgType><![CDATA[text]]></MsgType>\n" +
                "  <Content><![CDATA[感谢您的关注！！]]></Content>\n" +
                "</xml>";
        return msg;
    }
}
